﻿using System;
using System.Collections.Generic;
using System.Windows.Navigation;

namespace DotNet.Phone8.MvvmLight.Extensions
{
    public class NavigationParamsEventArgs : EventArgs
    {
        public NavigationParamsEventArgs(NavigationUri uri, NavigationMode navigationMode)
        {
            this.uri = uri;
            this.navigationMode = navigationMode;
        }

        private NavigationMode navigationMode;

        //
        // Summary:
        //     Gets a value that indicates whether the navigation is forward, back, or a
        //     new navigation.
        //
        // Returns:
        //     A value that indicates whether the navigation is forward, back, or a new
        //     navigation. The default is System.Windows.Navigation.NavigationMode.New.
        public NavigationMode NavigationMode
        {
            get
            {
                return navigationMode;
            }
        }

        //
        // Summary:
        //     Gets the uniform resource identifier (URI) of the target.
        //
        // Returns:
        //     A value that represents the URI.
        public NavigationUri Uri
        {
            get
            {
                return uri;
            }
        }

        private NavigationUri uri;

        public TParaValue GetParamater<TParaKey, TParaValue>(TParaKey key)
        {
            if (uri != null)
            {
                return uri.GetParamater<TParaKey, TParaValue>(key);
            }
            else
            {
                return default(TParaValue);
            }
        }

        public bool ContainsParameter<TParaKey>(TParaKey key)
        {
            if (uri != null)
            {
                return uri.ContainsParameter(key);
            }
            else
            {
                return false;
            }

        }

        public Dictionary<object, object> GetAllParameters()
        {
            if (uri != null)
            {
                return uri.GetAllParameters();
            }
            else
            {
                return null;
            }
        }
    }
}
